const state = {
  appointmentInfo: [
    {
      name: "李春华",
      sex: "女",
      time: "9:00-10:00",
      phoneNumber: 13012312311,
      // 备注
      remark: "无",
      // 测量值
      condition: {
        stature: "170cm",
        weight: "60kg",
        temperature: "36.7°C",
        DBP: "未测",
        SBP: "未测",
      },
      doctor: { name: "李医生", project: "儿科" },
      time: "09:00~10:00",
      age: 30,
      date: "2017-8-9",
      indentTime: "9:00",
      appointmentType: "儿科",
      // 就诊时间
      appointmentTime: "2017-8-10 10:00",
      // 是否已到
      isArrive: 0,
      // 描述
      describe:
        "发热，感到不舒服，之前几天一直睡不着，吃了药也没用............",
      // 病史
      history: [
        { name: "急性坏疽性阑尾炎伴穿孔", date: "2017-04-25  11:55:50" },
        { name: "副伤寒", date: "2017-04-12  10:00:00" },
      ],
      // 体格检查
      examine: "暂无信息",
      // 辅助检查
      subsidiaryexamine: "暂无信息",
      // 诊断
      diagnose: "请输入....",
      // 药方
      prescription: "",
      // 是否缴费
      isPay: 0,
      // 是否初诊
      isFrist:"1",
      // 医生给的诊断
      prescription:{
        history:"病史对该症状无影响",
        examine:"",
        subsidiaryexamine:"",
        result:""
      },
      //医嘱
      medicine: [],
      //订单
      indent: [
        {
          dragName: "挂号费",
          price: 32,
          isactive: true,
        },
      ]

        // 数据
    }
  ]
}
const mutations = {

  receiveCondition(state, condition) {
    state.condition = condition
  },
  receiveTime(state, { appointmentTime }) {
    state.appointmentTime = appointmentTime
  },
  deleteReservation(state, { appointmentInfo, index }) {
    state.appointmentInfo.shift()
  },
  // 提交医生的诊断
  changePrescription(state,value){
   
    state.appointmentInfo[0].prescription = value
    console.log(state)
  },
  // 更改病人的基本信息
  changeCondition(state, value){
    state.appointmentInfo[0].condition = value
  },
  // 下一位病人
  nextpatient(state){
    state.appointmentInfo.shift()
  },
  // 清空病人
  clearPatient(state){
      state.appointmentInfo = []
  },
  //点击新增医嘱
  ADD_MEDICINE(state, medicine) {
    state.appointmentInfo[0].medicine.push(medicine);
  },
  //点击删除
  DELETE_MEDICINE(state, index) {
    state.appointmentInfo[0].medicine.splice(index, 1);
  },
  //点击修改
  CHANGE_MEDICINE(state, info) {
    let { index, medicine } = info;
    state.appointmentInfo[0].medicine.splice(index, 1, medicine);
  },
  //点击新增订单
  ADD_INDENT(state, medicine) {
    state.appointmentInfo[0].indent.push(medicine);
  },
  //点击删除
  DELETE_INDENT(state, index) {
    state.appointmentInfo[0].indent.splice(index, 1);
  },
  //点击修改
  CHANGE_INDENT(state, info) {
    let { index, medicine } = info;
    state.appointmentInfo[0].indent.splice(index, 1, medicine);
  },
  //点击缴费完成订单
  FINISH_INDENT(state, index) {
    state.appointmentInfo[0].indent.splice(
      index,
      state.appointmentInfo[0].indent.length
    );
  },
  // 获取编辑的mutations
  getAppointmentInfo(state, appointmentInfo) {
    state.appointmentInfo[0].condition = appointmentInfo;
  },

}
const actions = {

}
const getters ={

}
export default{
  state,
  mutations,
  actions,
  getters,
};
